import request from '../request'
import { AxiosResponse } from 'axios'
import { LoginFrom } from '@/types/views/login'
import { ResponseData } from '@/types/api/public'
import { LoginSuccess, UserInfo, RouterData, RouterObj } from '@/types/api/login'

type ConfigType<T=ResponseData> = Promise<AxiosResponse<T>>

/**
 * @desc: 登录
 * @param { Object } data 输入的账号密码
 */
export const login = (data: LoginFrom): ConfigType<any> => {
  return request({
    url: '/Account/Login',
    method: 'post',
    data
  })
}

/**
 * @desc: 获取用户信息
 * @returns data
 */
export const info = (): ConfigType<any> => {
  return request({
    url: '/User/UserInfo',
    method: 'get'
  })
}

/**
 * @desc: 获取验证码
 * @returns data
 */
export const getValidateCode = (params:any): ConfigType<any> => {
  return request({
    url: '/Tool/ValidateCodeStr',
    method: 'get',
    params
  })
}


/**
 * @desc: 获取菜单
 */
export const menu = (): ConfigType<any> => {
  return request({
    url: '/Menu/QueryUserMenus',
    method: 'get'
  })
}


/**
 * @desc: 退出登录
 */
 export const logout = (): ConfigType => {
  return request({
    url: '/logout',
    method: 'post'
  })
}